/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utilities;

import entities.Admin;
import entities.DoctorDetails;
import entities.StaffDetail;
import java.util.ArrayList;

/**
 *
 * @author VietLH
 */
public class LoginManage {
    private ArrayList<DoctorDetails> doctorList;
    private ArrayList<StaffDetail> staffList;
    private Admin admin;

    public LoginManage(ArrayList<DoctorDetails> doctorList, ArrayList<StaffDetail> staffList, Admin admin) {
        this.doctorList = doctorList;
        this.staffList = staffList;
        this.admin = admin;
    }

    public LoginManage() {
    }
    
    public Object checkLogin(int roll,String username,char[] password){
        String cPassword="";
        for(int i=0;i<password.length;i++){
            cPassword+=password[i];
        }
        if (roll ==1){
            for (StaffDetail staff : staffList) {
                if((staff.getStaffUsername().compareTo(username)==0)&&(staff.getStaffPassword().compareTo(cPassword)==0)){
                    return staff;
                }
            }
            return null;
        }
        if (roll ==2){
            for (DoctorDetails doctor : doctorList) {
                if((doctor.getdUsername().compareTo(username)==0)&&(doctor.getPassword().compareTo(cPassword)==0)){
                    return doctor;
                }
            }
            return null;
        }
        if (roll ==3){
            if(admin.getaPassword().compareTo(cPassword)==0){
                return admin;
            }
            return null;
        }
        return null;
    }
}
